module.exports = app => {
    const { STRING, INTEGER } = app.Sequelize;

    const TopicLesson = app.model.define('topic-lesson', {
        topicId: {
            type: INTEGER,
            allowNull: false,
        },
        title: {
            type: STRING(255),
            allowNull: false,
        },

        coverImage: {
            type: STRING(255),
            allowNull: true,
        },

        questionCount: {
            type: INTEGER,
            allowNull: false,
            defaultValue: 20,
        },
        passRate: {
            type: INTEGER,
            defaultValue: 60,
        },

        certificateConfigId: {
            type: INTEGER,
            allowNull: true,
        },


        desc: {
            type: STRING(255),
            allowNull: true,
        },

    }, {
        timestamps: true,
        underscored: false,
    });


    TopicLesson.associate = function () {
        TopicLesson.Topic = TopicLesson.belongsTo(app.model.Topic, {
            foreignKey: "topicId",
            as: "topic"
        });
    };

    return TopicLesson;
};
